const db = require('./db')
const mysql = require('mongoose');
const { any } = require('joi');

// 用户集合
const UserSchema = new mysql.Schema({
  username: {
    type: String,
    unique: true
  },
  password: String,
  nickname: String,
  // 收藏数据
  collectArr: Array,
  // 点赞数据
  likeArr: Array,
  avatar: String,
})
// mysql.model('ProjectInfo', ProjectSchema)

// 文章集合
const ArticleSchema = new mysql.Schema({
  // 作者id
  u_id: {
    type: String,
  },
  // 作者姓名
  author: {
    type: String,
  },
  title: {
    type: String,
  },
  // 用户头像
  avatar: {
    type: String
  },
  // 文章内容
  content: {
    type: String,
  },
  // 文章图片
  pic: {
    type: Array
  },
  creatTime: String,
  likeNum: Number,
  commentNum: Number,
  collectNum: Number,
})

// 点赞集合
const LiskSchemea = new mysql.Schema({
  // 用户id
  u_id: String,
  // 文章id
  article_id: String
})

// 添加好友通知
const FriendsNotice = new mysql.Schema({
  u_id: String, // 自己的id
  userInfo: Object, // 发送人的姓名
  friend_id: String, // friend Id
})

// 好友列表
const FriendList = new mysql.Schema({
  u_id: String,
  friend_id: String,
  friend_info: Object,
  u_info: Object,
})
// function Myfind(data) {
//   Modal.find(data).lean().exec((err, results) => {
//     if (err) return res.cc(err)
//     return results
//   })
// }
// const ArticleModal = mysql.model('My_db_01', ArticleSchema, 'ev_article')

module.exports = {
  Modal: mysql.model('Ev_user', UserSchema, 'ev_users'),
  ArticleSchema: mysql.model('Ev_article', ArticleSchema, 'ev_articles'),
  LikeSchema: mysql.model('Ev_like', LiskSchemea, 'ev_like'),
  FriendSchema: mysql.model('Ev_friends_notice', FriendsNotice, 'ev_friends_notice'),
  FriendListSchema: mysql.model('Ev_friends', FriendList, 'ev_friend'),
  // ArticleModal
}
// exports.Modal = Modal
// exports